﻿import QtQuick
import QtQuick.Controls
import QtQuick.Controls.Basic
import FilUI

Button {
    id: control

    property bool disabled                      : false
    property string contentDescription          : ""
    property color normalColor                  : Qt.rgba(254/255, 254/255, 254/255, 1)
    property color hoverColor                   : Qt.rgba(246/255, 246/255, 246/255, 1)
    property color disableColor                 : Qt.rgba(251/255, 251/255, 251/255, 1)
    property color dividerColor                 : Qt.rgba(233/255, 233/255, 233/255, 1)
    property color textColor                    : {
        if (!enabled) {
            return Qt.rgba(160/255, 160/255, 160/255, 1)
        }
        if (pressed) {
            return Qt.rgba(96/255, 96/255, 96/255, 1)
        }
        return Qt.rgba(0, 0, 0, 1)
    }

    Accessible.role                             : Accessible.Button
    Accessible.name                             : control.text
    Accessible.description                      : contentDescription
    Accessible.onPressAction                    : control.clicked()
    enabled                                     : !disabled
    verticalPadding                             : 0
    horizontalPadding                           : 12
    font                                        : FilTextStyle.Body
    focusPolicy                                 : Qt.TabFocus
    background                                  : FilControlBackground {
        implicitWidth                           : 30
        implicitHeight                          : 30
        radius                                  : 4
        color                                   : {
            if (!enabled) {
                return disableColor
            }
            return hovered ? hoverColor : normalColor
        }
        shadow                                  : !pressed && enabled
        FilFocusRectangle {
            visible                             : control.activeFocus
            radius                              : 4
        }
    }
    contentItem                                 : FilText {
        text                                    : control.text
        horizontalAlignment                     : Text.AlignHCenter
        verticalAlignment                       : Text.AlignVCenter
        font                                    : control.font
        color                                   : control.textColor
    }

}
